package com.example.demo.practice.monitoring;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.example.demo.practice.R;
import com.example.demo.practice.innerclass.IBaseActivity;
import com.example.demo.practice.ui.WaveProgressView;

public class WaterLevelShow extends IBaseActivity {

    private WaveProgressView waveProgressView;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_water_level_show);
            Intent intent = getIntent();
            String code = intent.getStringExtra("code");
            setTitle("水位" + code);
            String company = intent.getStringExtra("company");
            String address = intent.getStringExtra("address");
            int state=0;
            String states=intent.getStringExtra("state");
            if(!states.equals("")){
                state = Integer.parseInt(states);
            }

            TextView textView1 = (TextView) findViewById(R.id.code);
            code = "编号:" + code;
            textView1.setText(code);
            TextView textView2 = (TextView) findViewById(R.id.company);
            company = "单位:" + company;
            textView2.setText(company);
            TextView textView3 = (TextView) findViewById(R.id.address);
            address = "地址:" + address;
            textView3.setText(address);
            waveProgressView = (WaveProgressView) findViewById(R.id.waveProgress);
            waveProgressView.setWaveColor("#f0b55e");
            waveProgressView.setCurrent(state, state + "%");

            final WaterBundle bubbleLayout = (WaterBundle) findViewById(R.id.bubble_layout);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    while (!Thread.currentThread().isInterrupted()) {
                        try {
                            Thread.sleep(15);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        bubbleLayout.postInvalidate();
                    }
                }
            }).start();
        }
    }
